#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
LL s[N];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		scanf("%d", &n);
		memset(s, 0, sizeof(s));
		for (int i = 1; i <= n; i++) {
			LL x;
			scanf("%lld", &x);
			s[i] += s[i - 1] + x;
		}
		LL ma = 0;
		for (int i = 1; i < n - 1; i++) {
			ma = max(ma, s[i] * 114 + (s[n] - s[i]) * 514);
		}
		printf("%lld\n", ma);
	}
	return 0;
}